<template>
  <div>
    <!-- 最上面 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <!-- 第一层搜索框和按钮 -->
      <el-input placeholder="请输入内容" style="width: 400px" clearable>
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>

      <!-- 第二层的表单 -->
      <el-table :data="orderList" stripe border style="width: 100%">
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格"> </el-table-column>
        <el-table-column prop="order_pay" label="是否付款"> </el-table-column>
        <el-table-column prop="is_send" label="是否发货"> </el-table-column>
        <el-table-column prop="create_time" label="下单时间"> </el-table-column>
        <el-table-column label="操作"> </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //订单列表
      orderList: [],
      //获取列表要传递的参数
      orderParams: {
        query: "",
        pagenum: 1,
        pagesize: 12
      },
      //订单列表数据总数
      total: 0
    };
  },
  created() {
    this.getOrderList();
  },
  methods: {
    //获取订单列表
    async getOrderList() {
      const { data: res } = await this.$http.get("orders", {
        params: this.orderParams
      });
      if (res.meta.status !== 200) {
        return this.$message.error("获取订单列表失败");
      }
      this.$message.success("获取订单列表成功");
      this.orderList = res.goods;
      this.total = res.total;
      console.log(res.data);
    }
  }
};
</script>

<style lang="less"></style>
